package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.OrdinaryScore;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrdinaryScoreMapper {

    @Insert("<script>insert into ordinaryscore(oid,mid,year) values " +
            "<foreach collection = 'list' item='record' separator=',' >" +
            "(#{record.oid},#{record.mid},#{record.year})" +
            "</foreach></script>")
    int addOrdinaryScoreMult(List<OrdinaryScore> list);

    @Select("select * from ordinaryscore where oid=#{oid} and mid=#{mid}")
    OrdinaryScore selectByOAndMId(@Param("oid") String oid, @Param("mid")String mid);

    @Select("select * from ordinaryscore where oid=#{oid}")
    List<OrdinaryScore> selectOrdinaryScoreByOId(String oid);

    @Update("<script>update ordinaryscore set item1=#{item1},item2=#{item2},item3=#{item3},item4=#{item4}," +
            "item5=#{item5},score=#{score},submittime=now()," +
            "status=1,flag=0,year=#{year}<if test=\"description != null and description != '' \">,description=#{description}</if> " +
            "where oid=#{oid} and mid=#{mid}</script>")
    int updateLeaderScore(OrdinaryScore ordinaryScore);

    @Update("update ordinaryscore set submittime=now(),flag=1 where oid=#{oid} and mid=#{mid}")
    int updateOrdinaryScoreQuit(@Param("oid") String oid, @Param("mid")String mid);

    @Select("select * from ordinaryscore where mid=#{mid}")
    List<OrdinaryScore> selectOrdinaryScoreByMid(String mid);

    @Select("select * from ordinaryscore where oid=#{oid}")
    List<OrdinaryScore> selectOrdinaryScoreByOid(String oid);
}
